To effectively control large-scale outbreak, the propagation properties of the leeching P2P (Peer-to-Peer) botnet was studied using dynamics theory. Firstly, a delayed differential-equation model was proposed according to the formation of the botnet. Secondly, the threshold expression of controlling botnet was obtained by the explicit mathematical analysis. Finally, the numerical simulations verified the correctness of theoretical analysis. The theoretical analysis and experimental results show that the botnet can be completely eliminated if the basic reproduction number is less than 1. Otherwise, the defense measures can only reduce the scale of botnet. The simulation results show that decreasing the infection rate of bot programs or increasing the immune rate of nodes in the network can effectively inhibit the outbreak of botnet. In practice, the propagation of bot programs can be controlled by some measures, such as uneven distribution of nodes in the network, timely downloading patch and so on.